package com.turnengine.client.local.unit.bean;

import com.javabi.common.io.data.IDataReader;
import com.javabi.common.io.data.IDataWriter;
import java.io.IOException;

/**
 * The Storage Group Serializer.
 */
public class StorageGroupSerializer implements IStorageGroupSerializer {

	@Override
	public IStorageGroup readObject(IDataReader reader) throws IOException {

		// Read fields
		int parent = reader.readInt();
		int group = reader.readInt();
		long capacity = reader.readLong();

		// Create object
		IStorageGroup object = new StorageGroup();
		object.setParent(parent);
		object.setGroup(group);
		object.setCapacity(capacity);
		return object;
	}

	public void writeObject(IDataWriter writer, IStorageGroup object) throws IOException {

		// Get fields
		int parent = object.getParent();
		int group = object.getGroup();
		long capacity = object.getCapacity();

		// Write fields
		writer.writeInt(parent);
		writer.writeInt(group);
		writer.writeLong(capacity);
	}
}
